package com.timoon.testng;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Panel;

import com.googlecode.wicket.jquery.ui.form.button.AjaxButton;

/**
 *<p></p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */

public class FunShowPanel extends Panel {

	Integer count=0;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public FunShowPanel(String id) {
		super(id);
		

		//label是wicket自带的，简单的文字输出控件
		//下面的语句是把count的值(0)输出到界面【counter】
		final Label label=new Label("counter",count);
		add(label);
		
		//注册button
		AjaxButton button=new AjaxButton("btn") {
			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
				// TODO Auto-generated method stub
				
				//每一次点击这个按钮会执行此方法
				//此方法的目的是将count自增1，然后将label刷新到界面
				//局部刷新就这么简单
				
				count++;
				addOrReplace(label);
			}
		};
	}

}
